package net.maku.association.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.maku.framework.common.utils.PageResult;
import net.maku.framework.common.utils.Result;
import net.maku.association.convert.InterestAssociationMemberConvert;
import net.maku.association.entity.InterestAssociationMemberEntity;
import net.maku.association.service.InterestAssociationMemberService;
import net.maku.association.query.InterestAssociationMemberQuery;
import net.maku.association.vo.InterestAssociationMemberVO;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import java.util.List;

/**
* 兴趣协会成员
*
* @author 阿沐 babamu@126.com
* @since 1.0.0 2025-04-26
*/
@RestController
@RequestMapping("association/member")
@Tag(name="兴趣协会成员")
@AllArgsConstructor
public class InterestAssociationMemberController {
    private final InterestAssociationMemberService interestAssociationMemberService;

    @GetMapping("page")
    @Operation(summary = "分页")
    public Result<PageResult<InterestAssociationMemberVO>> page(@ParameterObject @Valid InterestAssociationMemberQuery query){
        PageResult<InterestAssociationMemberVO> page = interestAssociationMemberService.page(query);

        return Result.ok(page);
    }

    @GetMapping("{id}")
    @Operation(summary = "信息")
    public Result<InterestAssociationMemberVO> get(@PathVariable("id") Long id){
        InterestAssociationMemberEntity entity = interestAssociationMemberService.getById(id);

        return Result.ok(InterestAssociationMemberConvert.INSTANCE.convert(entity));
    }


}